﻿using InitQ.Abstractions;
using InitQ.Attributes;
using InitQ.Cache;
using Smart.Admin.Domain.Model.Const;
using Smart.Admin.Domain.Model.Entity;
using Smart.Admin.Domain.Service;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Smart.Admin.Domain.Subscribe
{
    public class TaskSubscrite : IRedisSubscribe
    {
        private readonly IServiceProvider _provider;

        public TaskSubscrite(IServiceProvider provider)
        {
            _provider = provider;
        }


      
        [Subscribe(RedisMapp.smart_admin_test_queue_B_c)]
        private async Task TestBc(string msg)
        {
            Console.WriteLine(msg + "在睡觉----->B业务");
        }


        /// <summary>
        /// 持久化访问日志
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        //[Subscribe(RedisMapp.mes_sys_queue_manager_log)]
        //private async Task SyncManagerLog(string msg) 
        //{
        //    //var model = JsonConvert.DeserializeObject<ManagerLogEntity>(msg);
        //    //if (model != null)
        //    //{
        //    //    using (var scope = _provider.GetRequiredService<IServiceScopeFactory>().CreateScope())
        //    //    {
        //    //        var _managerLogService = scope.ServiceProvider.GetService<ManagerLogService>();
        //    //        await _managerLogService.AddManagerLog(model);
        //    //    }
        //    //}
        //}

    }
}
